<?php

class Pagination {
	
	public function __construct($url, $totalPages, $currentPage, $divId) {
		$this->generate($url, $totalPages, $currentPage, $divId);
	}
	
	protected function generate($url, $totalPages, $currentPage, $divId) {
		$indice = 1;
		echo "<div id=\"$divId\">\n";
		
		while( $indice <= $totalPages ) {
			if( $indice == $currentPage ) {
				echo "&nbsp;&nbsp;<b>$indice</b>&nbsp;&nbsp;";
			} else {
				echo "&nbsp;&nbsp;<a href=\"$url?page=$indice\">$indice</a>&nbsp;&nbsp;";
			} 
			$indice = $indice + 1;
		}
		
		echo "\n</div>\n";
	}
}
?>